<?php
/**
 * Created by PhpStorm.
 * User: ysongyang
 * Date: 2016/6/7
 * Time: 13:06
 */
namespace Admin\Controller;
use Think\Controller;
class UploadController extends Controller{



    public function uploadify(){
        if(!IS_POST) $this->error('非法请求');
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     2048000 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload -> rootPath  = './Uploads/thumb/'; // 设置附件上传根目录
        $upload -> savePath = '';
        // 设置附件上传（子）目录
        $upload -> subName = array('date', 'Ymd');;
        // 上传单个文件
        $info   =   $upload->uploadOne($_FILES['Filedata']);
        /* 记录图片信息 */
        if($info){
            $return['status'] = 1;
            $return['info']=$info['savepath'].$info['savename'];
        } else {
            $return['status'] = 0;
            $return['info']   = $upload->getError();
        }
        /* 返回JSON数据 */
        $this->ajaxReturn($return);

    }
}